<template>
    <basic-container>
        <div style="width:50%;margin-top: 10px;">
            <avue-form ref="form" v-model="obj" :option="option"  @submit="submit">
            </avue-form>
        </div>
    </basic-container>
</template>
<script>
    import {
        getLive,
        setLive,
    } from '@/api/base/sysSet/liveSet'
    import {
        convertAddCode
    } from '@/util/util';
    export default {
        data() {
            return {
                obj:{},
                option:{
                    emptyBtn:false,
                    labelWidth:'200',
                    labelPosition:'left',
                    column: [{
                        label: "推流域名",
                        prop: "tencent_cloud_pushDomain",
                        tip:'推流域名',
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入推流域名",
                            trigger: "blur"
                        }]
                    },{
                        label: "拉流域名",
                        prop: "tencent_cloud_pollDomain",
                        tip:'拉流域名',
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入拉流域名",
                            trigger: "blur"
                        }]

                    },{
                        label: "应用名称",
                        prop: "tencent_cloud_appName",
                        tip:'应用名称',
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入应用名称",
                            trigger: "blur"
                        }]

                    },{
                        label: "apiKey",
                        prop: "tencent_cloud_apiKey",
                        tip:'apiKey',
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入apiKey",
                            trigger: "blur"
                        }]

                    }]
                }
            }
        },
        created(){
            this.getData()
        },
        methods:{
            getData(){
                getLive().then(res=>{
                    if(res.data.code==200){
                        this.obj=res.data.data
                    }
                })
            },
            submit (form,done) {
                convertAddCode(this.obj.tencent_cloud_apiKey,data=>{
                    this.obj.tencent_cloud_apiKey = data;
                });
                setLive(this.obj).then(res=>{
                           done()
                        this.$message({
                            message:'提交成功',
                            type:'success'
                        })
                        this.getData()


                })

            },
        }
    }

</script>
<style>
    h5{
        color: darkred;
        font-weight: bold;
    }
    p{
        line-height: 30px;
    }
</style>